package com.lesserpand.rabbitmq.quartz.job;

import org.quartz.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.redis.core.RedisTemplate;

import javax.annotation.Resource;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author bailuo
 * @version 2.0
 * @Description 具体业务逻辑
 * @Date Created in 2019/1/19 17:01
 */
public class HelloJob implements Job {

    private static final Logger LOGGER = LoggerFactory.getLogger(HelloJob.class);

    private Map<String, Object> jobDataMap;

    @Resource
    private RedisTemplate redisTemplate;

    public Map<String, Object> getJobDataMap() {
        return jobDataMap;
    }

    public void setJobDataMap(Map<String, Object> jobDataMap) {
        this.jobDataMap = jobDataMap;
    }

    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        LOGGER.info("hello job");
        // todo 具体业务逻辑



        // 业务数据保存定时任务中， JobDataMap：如果有业务数据需要保存到定时任务中，可以放到jobDataMap中
        Map<String, Object> jobDataMap = new ConcurrentHashMap<>();
        jobDataMap.put("jobKey", "SyncLocationDataToMongoJob");
        this.setJobDataMap(jobDataMap);
    }
}
